# !/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project ：tools 
@File ：wechat_push.py
@IDE  ：PyCharm 
@Author ：李涵彬
@Date ：2025/1/21 上午11:04 
"""

import requests


class WeChatPush:
	def __init__(self, push_key):
		"""
		初始化微信消息推送模块。
		:param push_key: 方糖推送的 PUSH_KEY
		"""
		self.push_key = push_key
		self.base_url = f"https://sc.ftqq.com/{self.push_key}.send"

	def send_message(self, title, content):
		"""
		发送微信消息。
		:param title: 消息标题
		:param content: 消息内容
		:return: 推送响应内容
		"""
		data = {
			"text": title,
			"desp": content
		}
		response = requests.post(self.base_url, data=data)
		return response.text


# 示例用法
if __name__ == '__main__':
	push_key = 'SCT223730TpAaEkEqs3V3RvoavFlUF5MKY'
	wechat_push = WeChatPush(push_key)
	response = wechat_push.send_message("这是测试信息标题", "这是测试信息内容")
	print("推送结果：", response)
